{# tooltip contains non-breaking spaces between fluffy and cloud #}{%- set search_tooltip = 'The search function is primitive. It only searches for the literal string as entered. "fluffy cloud" will only search the exact string "fluffy cloud", and not "fluffy" OR "cloud". Search is case insensitive, HTML tags and some special characters are stripped.' -%}
{# only needed for the og: meta properties in <head> #}
{%- if config.tagblog.site_url is defined -%}
{%- set tb_site_url = config.tagblog.site_url -%}{%- else -%}{%- set tb_site_url = config.base_url -%}
{%- endif -%}<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"><meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
    <title>{%- if meta.title -%}{{- meta.title }} | {% endif %}{{- site_title -}}</title>
    <link rel="icon" type="image/x-icon" href="/favicon.ico">
    {%- if meta.description -%}<meta name="description" content="{{- meta.description -}}"/>
        {# i don't understand what og:... is good for. i hope i'm doing this right. #}
        <meta property="og:description" content="{{- meta.description -}}"/>{%- endif -%}
    {%- if meta.robots -%}
        <meta name="robots" content="{{- meta.robots -}}">{%- endif -%}
    {# i don't understand what og:... is good for. i hope i'm doing this right. #}
    <meta property="og:type" content="{{- current_page.meta.template|default("index or other") -}}"/>
    <meta property="og:title" content="{{- current_page.title }} | {{ site_title -}}"/>
    <meta property="og:url" content="{{- tb_site_url -}}{{- current_page.id -}}"/>
    <meta property="og:site_name" content="{{- site_title -}}"/>
    {%- if current_page -%}
        <link rel="canonical" href="{{- tb_site_url -}}{{- current_page.id -}}" />
    {%- endif -%}
    <link rel="stylesheet" href="{{-theme_url-}}/css/style.css" type="text/css" />
    {# Loading color stylesheets #}<style>
    {%- if config.tagblog.colors  -%}
        {%- set style = config.tagblog.colors ~ ".css" -%}
        {%- include [ ( 'css/generated/custom-' ~ style ), ( 'css/custom-' ~ style ), ( 'css/generated/' ~ style ), ( 'css/' ~ style ) ] ignore missing -%}
    {%- endif -%}
    {%- if config.tagblog.scrollbar_colors -%}
    html {
        scrollbar-color: var(--base0d,#0073b5) #00000000
    }
    ::-webkit-scrollbar-thumb {
            background: var(--base02,#d8d4cb)
    }
    {%- endif -%}
    @media screen and (min-width:768px){nav#menu-icon{background:unset}}{%- include theme_url ~ 'css/custom.css' ignore missing -%}</style>
    {%- if meta.css_extra -%}<link rel="stylesheet" href="{{- base_url -}}{{- meta.css_extra -}}" type="text/css" />{%- endif -%}
    {%- if config.tagblog.custom_header -%}{%- include config.tagblog.custom_header -%}{%- endif -%}
</head>
<body>
    <header>
        <div class="inner flexbox">
            {%- include 'includes/topmenu.twig' ignore missing -%}
            {%- include 'includes/sitelogo.twig' ignore missing -%}
            <div class="title">
                <a href="{{- base_url -}}/">{{- site_title -}}</a>
            </div>
        </div>
    </header>
    <div class="inner">
        <section id="sidebar">
            {# looping over all pages to pick out what we need (i.e. pages with tags) #}
            {%- set tag_count = {} -%} {# tag_count contains: tag : count of occurences #}
            {%- set tag_pages = {} -%} {# tag_pages contains: tag : page ids of occurences hash '#' separated #}
            {%- set aut_count = {} -%} {# aut_count contains: author : count of occurences #}
            {%- set aut_pages = {} -%} {# aut_pages contains: author : page ids of occurences hash '#' separated #}
            {%- set tbpages = {} -%} {# contains ALL pages to be considered, saves some cycles later on #}
            {%- for page in pages if page.meta.tags or page.meta.author -%}
                {%- if page.meta.tags -%}
                    {%- set tbpages = tbpages|merge([page]) -%}
                    {%- for tag in page.meta.tags|split(',') -%}
                        {# tag_count contains: tag : count of occurences #}
                        {%- set tag_count = tag_count|merge({(tag):(tag_count[tag] + 1)}) -%}
                        {# tag_pages contains: tag : page ids of occurences hash '#' separated #}
                        {%- set tag_pages = tag_pages|merge( { (tag) : (tag_pages[tag] ~ '#' ~ page.id) } ) -%}
                    {%- endfor -%}
                {%- endif -%}
                {%- if page.meta.author -%}
                    {%- set aut_count = aut_count|merge({(page.meta.author):(aut_count[page.meta.author] + 1)}) -%}
                    {%- set aut_pages = aut_pages|merge({(page.meta.author):(aut_pages[page.meta.author]~'#'~page.id)}) -%}
                {%- endif -%}
            {%- endfor -%}

            {# sort tag_count into tag_sorting, according to config options #}
            {%- set tag_sorting = {} -%}
            {%- if config.tagblog.tagsort.method == 'numerical' -%}
                {%- set tag_sorting = tag_count|sort -%}
            {%- elseif config.tagblog.tagsort.method == 'alphabetical' -%}
                {%- for tag in tag_count|keys|sort -%}
                    {%- set tag_sorting = tag_sorting|merge({(tag): tag_count[tag] }) -%}
                {%- endfor -%}
            {%- endif -%}
            {# ... and sort it back into tag_count array #}
            {%- if config.tagblog.tagsort.reverse -%}
                {%- set tag_count = tag_sorting|reverse -%}
            {%- else -%}
                {%- set tag_count = tag_sorting -%}
            {%- endif -%}

        <input id="menu-icon" type="checkbox"/>
        <label for="menu-icon">Menu</label>
        <nav id="menu-icon"> {# this nav's visibility is controled by the checkbox above! (mobile only) #}
        {%- include 'includes/sidebar-top.twig' ignore missing -%}
        {# Tag List #}
            {%- if config.tagblog.taglist.enabled and tag_count -%}
                <div class="tag_list">
                    {%- if config.tagblog.taglist.title -%}<div>{{- config.tagblog.taglist.title -}}</div>{%- endif -%}
                    <ul>
                        {%- for tag,total in tag_count -%}
                            <li>
                                <a href="{{- base_url -}}/tags?q={{- tag -}}">{{- tag -}}{%- if config.tagblog.tagcount.enabled -%}<span> ({{- total -}})</span>{%- endif -%}</a>
                            </li>
                        {%- endfor -%}
                    </ul>
                </div>
            {%- endif -%}

        {# Tag Cloud #}
            {%- if config.tagblog.tagcloud.enabled and tag_count -%}

                {# Levels Validation  #}
                {%- if max(tag_count) < config.tagblog.tagcloud.maxoccur -%}
                    {%- set tagmaxoccur = max(tag_count) -%}
                {%- else -%}
                    {%- set tagmaxoccur = config.tagblog.tagcloud.maxoccur -%}
                {%- endif -%}

                {# Render Tag Cloud #}
                <div class="tag_cloud">
                    {%- if config.tagblog.tagcloud.title -%}<div>{{- config.tagblog.tagcloud.title -}}</div>{%- endif -%}
                    <ul>
                        {%- for tag,total in tag_count -%}
                            {%- if total > tagmaxoccur -%}{%- set size = tagmaxoccur -%}{%- else -%}{%- set size = total -%}
                            {%- endif -%}
                            {%- if size == 1 -%}{%- set fontsize = config.tagblog.tagcloud.fontsizemin -%}{%- set lettersp = 0 -%}
                                {%- else -%}
                                    {# calculate tag font size - https://stackoverflow.com/a/3717340 #}
                                    {%- set fontsize = ( (size / tagmaxoccur) * ( config.tagblog.tagcloud.fontsizemax - config.tagblog.tagcloud.fontsizemin ) + config.tagblog.tagcloud.fontsizemin ) -%}
                                    {%- set lettersp = ( fontsize/15 )|round(2) -%}
                            {%- endif -%}
                            <li>
                            <a href="{{- base_url -}}/tags?q={{- tag -}}"><span style="font-size:{{- fontsize -}}rem;letter-spacing:-{{- lettersp -}}rem">{{- tag -}}</span>{%- if config.tagblog.tagcount.enabled -%}<span>{{- total -}}</span>{%- endif -%}</a></li>
                        {%- endfor -%}
                    </ul>
                </div>
            {%- endif -%}
            <hr />
            <div class="clearfix">
                {%- if config.tagblog.search.enabled -%}
                {# searches go to the /search.md page #}
                <form class="search paragraph" id="search_form" action="/search">
                    {# <label for="search_input">Search» </label> #}
                    <span><input title='{{- search_tooltip -}}' class="submit" type="submit" value="Search" /></span>
                    <span><input pattern=".{0{{- config.tagblog.search.minlength -}},}" required title="{{- config.tagblog.search.minlength }} characters minimum" type="text" id="search_input" name="q" /></span>
                    <input id="titlesonly" type="checkbox" name="titlesonly" />
                    <label for="titlesonly">Titles only</label>
                </form>
                {%- endif -%}
                {%- if config.tagblog.feed.enabled -%}
                <div class="rss paragraph"><a href="{{- base_url -}}/feed">RSS Feed</a></div>
                {%- endif -%}
                {%- include 'includes/sidebar-bottom.twig' ignore missing -%}
            </div>
        <div class="desktop-device"><hr></div>
        <div class="desktop-device back_up"><a href="#">{{ config.tagblog.home|default('Top') }}</a></div>
        </nav>
        </section>
        <section class="content">
    {%- block content -%}
        {%- set count = tbpages|length -%}
        <h3>All Articles ({{- count -}})</h3>
        {%- set paging_url_base = current_page.url ~ '?' -%}
        {%- set paging_array = tbpages -%}
        {%- include 'includes/paging.twig' -%}
    {%- endblock -%}
        </section>
    </div>
    <footer>
        {%- include 'includes/footer.twig' ignore missing -%}
    </footer>
</body>
<!-- made with https://{notabug,framagit}.org/ohnonot/tagblog -->
</html>